const app = getApp()
Component({
  mixins: [],
  data: {
    menus: [{
      name: '我要加油1',
      imgUrl: '/components/menus/img/i_oil.png',
      url: 'pages/confirm/confirm',
      page: 'confirm'
    },
    {
      name: '我的订单1',
      imgUrl: '/components/menus/img/i_order.png',
      url: 'pages/order/order',
      page: 'order'
    },
    {
      name: '我的账户1',
      imgUrl: '/components/menus/img/i_wx.png',
      url: 'pages/my/my',
      page: 'my'
    },
    {
      name: '领取优惠券1',
      imgUrl: '/components/menus/img/i_ticket.png',
      url: 'pages/ticket/get/get',
      page: 'getTicket'
    },
    ]
  },
  props: {
    index: 0,
    open: false,
    holder: false
  },
  didMount() { },
  didUpdate() { },
  didUnmount() { },
  methods: {
    onMenus() {
      const open = this.data.open
      const holder = this.props.holder
      console.log(holder)
      this.setData({
        open: !open,
      })
      if (holder) {
        console.log('出')
      }
    },
    toPage(e) {
      const toUrl = e.currentTarget.dataset.url
      const toPage = e.currentTarget.dataset.page
      const modalOpened = app.globalData.modalOpened
      var currentPages = getCurrentPages()
      var currentPage = currentPages[currentPages.length - 1] //获取当前页面的对象
      var currentUrl = currentPage.route //当前页面url

      //     app.backMayi()
      if (toUrl != currentUrl) {
        if (toPage == 'getTicket') {
          // this.setData({
          //   showWebview: true,
          // })
          wx.alert({
            title: '很抱歉',
            content: '该功能暂未开通，敬请期待~',
            buttonText: '我知道了',
          });
        } else {
          wx.switchTab({
            url: 'page/my/my'
          })
        }
      }


    }
  },
});